[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
gets() Read a Line from 'Stdin'
#include <stdio.h>
char *gets(buffer);
char *buffer; Storage location for input string
gets() reads a string from the standard input 'stdin' and stores it
in 'buffer'. The string consists of all characters up to and
including the first new-line character ('\n'). The new-line
character is replaced in 'buffer' with a null character ('\0').
Returns: The string argument. A NULL pointer indicates an
error or end-of-file condition. Use ferror() or
feof() to determine whether an error or eof occurred.
-------------------------------- Example ---------------------------------
The following statements get a string from 'stdin' and print it to
the screen.
#include <stdio.h>
char buffr[80];
char *rslt;
main()
{
if (!feof(rslt = gets(buffr)))
printf("\n%s",rslt);
}
See Also:
fgets()
fputs()
puts()
feof()
ferror()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson